<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="topic1">
  <title>CREATE TEXT SEARCH TEMPLATE</title>
  <body>
    <section>
      <title>Description</title>
      <p id="sql_command_desc">Defines a new text search template.</p>
    </section>
    <section>
      <title>Synopsis</title>
    </section>
    <codeblock id="sql_command_synopsis">CREATE TEXT SEARCH TEMPLATE <varname>name</varname> (
    [ INIT = <varname>init_function</varname> , ]
    LEXIZE = <varname>lexize_function</varname>
)</codeblock>
    <section id="section3">
      <title>Description</title>
      <p><codeph>CREATE TEXT SEARCH TEMPLATE</codeph> creates a new text search template. Text
        search templates define the functions that implement text search dictionaries. A template is
        not useful by itself, but must be instantiated as a dictionary to be used. The dictionary
        typically specifies parameters to be given to the template functions.</p>
      <p>If a schema name is given then the text search template is created in the specified schema.
        Otherwise it is created in the current schema.</p>
      <p>You must be a superuser to use <codeph>CREATE TEXT SEARCH TEMPLATE</codeph>. This
        restriction is made because an erroneous text search template definition could confuse or
        even crash the server. The reason for separating templates from dictionaries is that a
        template encapsulates the "unsafe" aspects of defining a dictionary. The parameters that can
        be set when defining a dictionary are safe for unprivileged users to set, and so creating a
        dictionary need not be a privileged operation.</p>
      <p>Refer to <xref href="../../admin_guide/textsearch/full-text-search.html#full-text-search" format="html" scope="external">Using Full Text Search</xref>
        for further information.</p>
    </section>
    <section id="section4">
      <title>Parameters</title>
      <parml>
        <plentry>
          <pt><codeph><varname>name</varname></codeph></pt>
          <pd>The name of the text search template to be created. The name can be
            schema-qualified.</pd>
        </plentry>
        <plentry>
          <pt><codeph><varname>init_function</varname></codeph></pt>
          <pd>The name of the init function for the template.</pd>
        </plentry>
        <plentry>
          <pt><codeph><varname>lexize_function</varname></codeph></pt>
          <pd>The name of the lexize function for the template.</pd>
        </plentry>
      </parml>
      <p>The function names can be schema-qualified if necessary. Argument types are not given,
        since the argument list for each type of function is predetermined. The lexize function is
        required, but the init function is optional.</p>
      <p>The arguments can appear in any order, not only the order shown above.</p>
    </section>
    <section id="section7">
      <title>Compatibility</title>
      <p>There is no <codeph>CREATE TEXT SEARCH TEMPLATE</codeph> statement in the SQL standard.</p>
    </section>
    <section id="section8">
      <title>See Also</title>
      <p><codeph><xref href="DROP_TEXT_SEARCH_TEMPLATE.xml#topic1"/></codeph>, <codeph><xref
            href="ALTER_TEXT_SEARCH_TEMPLATE.xml#topic1"/></codeph>
      </p>
    </section>
  </body>
</topic>
